<?php

namespace app\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\AccessControl;

/**
 * Dashboard controller
 */
class DashboardController extends Controller {

    /**
     * @inheritdoc
     */
    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
        ];
    }

    /**
     * Displays homepage.
     *
     * @return mixed
     */
    public function actionIndex() {
        if (!Yii::$app->user->isGuest) {
            if (!Yii::$app->user->identity->profile->qq) {
                Yii::$app->session->addFlash('error', '请设置QQ号！');
                return $this->redirect(['user/settings/profile']);
            }
        }
        return $this->render('index');
    }

}
